home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / gs24src.zip / GS_INIT.PS < prev    next >
Text File  |  1992-03-24  |  26KB  |  810 lines

  1. %    Copyright (C) 1989, 1992 Aladdin Enterprises.  All rights reserved.
  2. %    Distributed by Free Software Foundation, Inc.
  3. %
  4. % This file is part of Ghostscript.
  5. %
  6. % Ghostscript is distributed in the hope that it will be useful, but
  7. % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. % to anyone for the consequences of using it or for whether it serves any
  9. % particular purpose or works at all, unless he says so in writing.  Refer
  10. % to the Ghostscript General Public License for full details.
  11. %
  12. % Everyone is granted permission to copy, modify and redistribute
  13. % Ghostscript, but only under the conditions described in the Ghostscript
  14. % General Public License.  A copy of this license is supposed to have been
  15. % given to you along with Ghostscript so you can know your rights and
  16. % responsibilities.  It should be in a file named COPYING.  Among other
  17. % things, the copyright notice and this notice must be preserved on all
  18. % copies.
  19.  
  20. % Initialization file for Ghostscript.
  21. % When this is run, systemdict is still writable.
  22.  
  23. % Acquire the debugging flags.
  24. currentdict /DEBUG known   /DEBUG exch def
  25.   /VMDEBUG
  26.     DEBUG {{vmstatus pop (      ) cvs print pop ( ) print
  27.             systemdict length (      ) cvs print (\n) print flush}}
  28.       {{}} ifelse
  29.   def
  30. currentdict /ASCIIOUT known   /ASCIIOUT exch def
  31. currentdict /DISKFONTS known   /DISKFONTS exch def
  32. currentdict /NODISPLAY known   not /DISPLAYING exch def
  33. currentdict /NOBIND known { /.bind /bind load def   /bind { } def } if
  34. currentdict /NOCACHE known   /NOCACHE exch def
  35. currentdict /NOPAUSE known   /NOPAUSE exch def
  36. currentdict /QUIET known ASCIIOUT or   /QUIET exch def
  37. currentdict /WRITESYSTEMDICT known   /WRITESYSTEMDICT exch def
  38.  
  39. % Acquire environment variables.
  40. currentdict /DEVICE known not
  41.  { (GS_DEVICE) getenv { /DEVICE exch def } if } if
  42.  
  43. QUIET not { (Initializing... ) print flush } if
  44.  
  45. % Acquire systemdict and userdict.
  46. % Note that the dictionary stack only has 1 element at this point!
  47. /systemdict currentdict def
  48. /userdict 200 dict def
  49. userdict begin        % 2 elements now
  50. systemdict begin
  51.  
  52. VMDEBUG
  53.  
  54. % Define true and false.
  55. /true 0 0 eq def
  56. /false 0 1 eq def
  57.  
  58. % Acquire the standard files.
  59. /.stdin (%stdin) (r) file def
  60. /.stdout (%stdout) (w) file def
  61. /.stderr (%stderr) (w) file def
  62.  
  63. % Turn on array packing for the rest of initialization.
  64. true setpacking
  65.  
  66. % Define a special version of def for making operator procedures.
  67. /odef
  68.     {1 index exch makeoperator def} bind def
  69.  
  70. % Define predefined procedures substituting for operators,
  71. % in alphabetical order.
  72.  
  73. userdict /#copies 1 put
  74. /[    /mark load def
  75. /]     {counttomark array astore exch pop} odef
  76. /abs    {dup 0 lt {neg} if} odef
  77. /copypage
  78.     { 1 false .outputpage
  79.       (>>copypage, press <return> to continue<<\n) .confirm
  80.     } odef
  81. /defaultmatrix
  82.     {currentdevice exch deviceinitialmatrix} odef
  83. /.echo /echo load def
  84. userdict /.echo.mode true put
  85. /echo    {dup /.echo.mode exch store .echo} odef
  86. % <file> <dict> .eexec 
  87. /.eexec
  88.     { exch 55665 .filtereexecDecode
  89.       cvx systemdict begin exch begin stopped end end
  90.       $error /newerror get and {handleerror} if
  91.     } bind def
  92. /eexec
  93.     { systemdict .eexec
  94.     } odef
  95. /executive
  96.     { { prompt (%statementedit) (r) file
  97.         dup bytesavailable 0 lt
  98.          { .stdin bytesavailable 0 lt {closefile exit} if }
  99.         if cvx execute
  100.       } loop
  101.     } odef
  102. /framedevice
  103.     {.stderr (Warning: framedevice is an obsolete operator.\n) writestring
  104.      .stderr flushfile
  105.      pop pop pop setmatrix initclip} odef
  106. % See the definition of revision below.
  107. /gsversion
  108.     {revision 100 div} def
  109. /handleerror
  110.     {errordict /handleerror get exec} bind def
  111. /identmatrix
  112.     {{1.0 0.0 0.0 1.0 0.0 0.0} cvlit exch copy} odef
  113. /initgraphics
  114.     {initmatrix newpath initclip 1 setlinewidth 0 setlinecap 0 setlinejoin
  115.      [] 0 setdash 0 setgray 10 setmiterlimit} odef
  116. /initmatrix
  117.     {.tempmatrix defaultmatrix setmatrix} odef
  118. /matrix    {6 array identmatrix} odef
  119. /prompt    {flush flushpage
  120.      (GS) print count 0 ne
  121.       {(<) print count =only}
  122.      if (>) print flush} bind def
  123. /pstack    {0 1 count 3 sub {index ==} for} def
  124. /quit    {0 .quit} odef
  125. % The "revision" is the Ghostscript release number x 100.
  126. /revision 240 def
  127. /run    {dup type /filetype eq
  128.       { true }
  129.       { findlibfile { exch pop true } { false } ifelse }
  130.      ifelse
  131.       {cvx execute}
  132.       {(r) file}        % let the error happen
  133.      ifelse} odef
  134. /showpage
  135.     { #copies true .outputpage
  136.       (>>showpage, press <return> to continue<<\n) .confirm
  137.       erasepage initgraphics
  138.     } odef
  139. % Code output by Adobe Illustrator relies on the fact that
  140. % `stack' is a procedure, not an operator!!!
  141. /stack    {0 1 count 3 sub {index =} for} bind def
  142. /start    { QUIET not
  143.       {(Ghostscript ) print gsversion =only ( (3/25/92)\n) print
  144.        (  Copyright (C) 1990, 1992 Aladdin Enterprises, Menlo Park, CA.\n) print
  145.        (  All rights reserved.\n) print
  146.        (Distributed by Free Software Foundation, Inc.\n) print
  147.        (Ghostscript comes with NO WARRANTY: see the file LICENSE for details.\n) print
  148.        flush
  149.       } if
  150.       executive
  151.     } def
  152. % Ghostscript is compatible with PostScript "version" 54.0 (I think).
  153. /version (54.0) def
  154.  
  155. % Provide semi-fake but usable definitions for
  156. % the color PostScript extensions (except for colorimage,
  157. % which is actually implemented as an operator).
  158. /setcmykcolor {
  159.     1 exch sub dup dup        % C, M, Y, S, S, S
  160.     6 -1 roll 1 exch sub mul    % M, Y, S, S, red
  161.     exch 5 -1 roll 1 exch sub mul    % Y, S, red, green
  162.     4 -2 roll exch 1 exch sub mul    % red, green, blue
  163.     setrgbcolor
  164. } odef
  165. /currentcmykcolor {
  166.     currentrgbcolor
  167.     3 { 1 exch sub 3 1 roll } repeat
  168.     0
  169. } odef
  170. /setblackgeneration {
  171.     pop
  172. } odef
  173. /currentblackgeneration {
  174.     {}
  175. } odef
  176. /setundercolorremoval {
  177.     pop
  178. } odef
  179. /currentundercolorremoval {
  180.     {}
  181. } odef
  182. /setcolorscreen {
  183.     setscreen 9 {pop} repeat
  184. } odef
  185. /currentcolorscreen {
  186.     currentscreen 3 copy 6 copy
  187. } odef
  188.  
  189. % Define the filter dictionary and operator.
  190.  
  191. /.filterdict mark
  192.     /ASCII85Encode /.filterASCII85Encode
  193.     /ASCII85Decode /.filterASCII85Decode
  194.     /ASCIIHexEncode /.filterASCIIHexEncode
  195.     /ASCIIHexDecode /.filterASCIIHexDecode
  196.     /eexecDecode /.filtereexecDecode
  197.     /LZWEncode /.filterLZWEncode
  198.     /LZWDecode /.filterLZWDecode
  199.     /NullEncode /.filterNullEncode
  200.     /PFBDecode /.filterPFBDecode
  201.     /RunLengthEncode /.filterRunLengthEncode
  202.     /RunLengthDecode /.filterRunLengthDecode
  203.     /SubFileDecode /.filterSubFileDecode
  204.     counttomark 2 idiv
  205.     dup dict begin
  206.      { dup where { pop load def } { pop pop } ifelse } repeat
  207.     pop
  208. currentdict end def
  209. /filter
  210.     { //.filterdict exch get exec
  211.     } odef
  212.  
  213. % Define procedures for getting and setting the current device resolution.
  214.  
  215. /gsgetdeviceprop
  216.  { 1 index getdeviceprops
  217.     { 1 index counttomark 1 add index eq { exit } if pop pop } loop
  218.    dup mark eq        % if true, not found
  219.     { pop dup /undefined signalerror }
  220.     { counttomark 1 add 1 roll cleartomark exch pop exch pop }
  221.    ifelse
  222.  } bind def
  223. /gscurrentresolution
  224.  { currentdevice /HWResolution gsgetdeviceprop
  225.  } bind def
  226. /gssetresolution
  227.  { 2 array astore mark exch /HWResolution exch
  228.    currentdevice copy putdeviceprops setdevice
  229.  } bind def
  230.  
  231. % Define simplified versions of the composite font operators
  232. % that work with (and only with) non-composite fonts.
  233.  
  234. /.encodingdict 3 dict
  235.     dup /StandardEncoding /StandardEncoding cvx put
  236.     dup /ISOLatin1Encoding /ISOLatin1Encoding cvx put
  237.     dup /SymbolEncoding /SymbolEncoding cvx put
  238.     def
  239. /cshow
  240.     { exch 1 string
  241.        { dup 0 4 index put stringwidth 3 -1 roll exec }
  242.       /exec cvx 4 array astore cvx
  243.       forall
  244.     } odef
  245. /findencoding
  246.     { //.encodingdict exch get exec } odef
  247. /rootfont
  248.     { currentfont } odef
  249. /setcachedevice2
  250.     { pop pop pop pop setcachdevice } odef
  251.  
  252. % Define some additional built-in procedures (beyond the ones defined by
  253. % the PostScript Language Reference Manual).
  254.  
  255. /concatprocs
  256.     { exch cvlit exch cvlit        % proc1 proc2
  257.       dup length 2 index length add array    % proc1 proc2 newproc
  258.       dup 0 4 index putinterval
  259.       dup 3 index length 3 index putinterval
  260.       exch pop exch pop cvx
  261.     } bind def
  262. /concatstrings
  263.     { 1 index length 1 index length add string
  264.       2 index 1 index copy pop
  265.       dup 3 index length 3 index length getinterval
  266.       2 index exch copy pop
  267.       exch pop exch pop
  268.     } bind def
  269. /copyarray
  270.     { dup length array copy } bind def
  271. /copystring
  272.     { dup length string copy } bind def
  273. /defaultdevice
  274.     { systemdict /DEVICE known
  275.        { systemdict /DEVICE get finddevice }
  276.        { 0 getdevice }
  277.       ifelse
  278.     } bind def
  279. /dicttomark        % (the Level 2 >> operator)
  280.     { counttomark 2 idiv dup dict begin
  281.        { def } repeat pop currentdict end
  282.     } bind def
  283. /finddevice
  284.     { systemdict /devicedict get exch get } bind def
  285. /selectdevice
  286.     { finddevice setdevice } bind def
  287. /signalerror        % object errorname
  288.     { errordict exch get exec } bind def
  289.  
  290. % Define auxiliary procedures needed for the above.
  291. /shellarguments        % -> shell_arguments true (or) false
  292.     { /ARGUMENTS where
  293.        { /ARGUMENTS get dup type /arraytype eq
  294.           { aload pop /ARGUMENTS null store true }
  295.           { pop false }
  296.          ifelse }
  297.        { false } ifelse
  298.     } bind def
  299. /.confirm
  300.     {DISPLAYING NOPAUSE not and
  301.       {% Print a message and wait for the user to type something.
  302.        % If the user just types a newline, flush it.
  303.        print flush
  304.        .echo.mode false echo
  305.          .stdin dup read
  306.          {dup (\n) 0 get eq {pop pop} {unread} ifelse} {pop} ifelse
  307.        echo}
  308.       {pop} ifelse} bind def
  309. /.identmatrix        % a read-only identity matrix
  310.     matrix readonly def
  311. /.tempmatrix        % a temporary matrix
  312.     matrix def
  313.  
  314. % Define the procedure used by the C executive for executing user input,
  315. % and also by the run operator.
  316. % This is called with a procedure or file on the operand stack.
  317. /execute
  318.     {stopped $error /newerror get and {handleerror} if} odef
  319.  
  320. % Define a special version of `run' that aborts on errors.
  321. /run0
  322.     { dup /.currentfilename exch def
  323.        { findlibfile not { stop } if }
  324.       stopped
  325.        { (Can't find initialization file ) print
  326.          .currentfilename = flush quit
  327.        } if
  328.       exch pop cvx stopped
  329.        { (While reading ) print .currentfilename print (:\n) print flush
  330.          handleerror quit
  331.        } if
  332.     } bind def
  333. % Temporarily substitute it for the real `run'.
  334. /.run /run load def
  335. /run /run0 load def
  336.  
  337. % If the user asked for ASCII output, read in the patches now.
  338. ASCIIOUT { (gs_2asc.ps) run } if
  339.  
  340. % Create the error handling machinery.
  341. % The interpreter has created the ErrorNames array.
  342. % Define $error.
  343. /$error 11 dict def        % newerror, errorname, command, errorinfo,
  344.                 % ostack, estack, dstack, recordstacks,
  345.                 % binary, .inerror, position
  346. $error begin
  347.   /newerror false def
  348.   /recordstacks true def
  349.   /binary false def
  350.   /.inerror false def
  351. end
  352. % Define errordict.  It has one entry per error name, plus handleerror.
  353. /errordict ErrorNames length 1 add dict def
  354. % Define the standard error handlers.  When they are invoked,
  355. % the top element of the o-stack is the error name;
  356. % the next element is the offending command.
  357. errordict begin
  358.   { //$error /.inerror get .instopped not or
  359.      { (Unrecoverable error: ) print =only flush
  360.        ( in ) print = flush
  361.        count 0 gt
  362.         { (Operand stack:\n  ) print
  363.       0 1 count 3 sub { (  ) print index =only flush } for
  364.       (\n) print flush
  365.     } if
  366.        quit
  367.      } if    % detect error recursion
  368.     $error /.inerror true put
  369.     $error /newerror true put
  370.     $error exch /errorname exch put
  371.     $error exch /command exch put
  372.     $error /dstack undef
  373.     $error /estack undef
  374.     $error /ostack undef
  375.     $error /recordstacks get $error /errorname get /VMerror ne and
  376.      { $error /dstack countdictstack array dictstack put
  377.        $error /estack countexecstack array execstack put
  378.        count array astore dup $error exch /ostack exch put
  379.      aload pop
  380.      } if
  381.     $error /.inerror false put
  382.     stop
  383.   } bind
  384.   ErrorNames
  385.    { [ 1 index 3 index /exec load ] cvx def
  386.    } forall
  387.   pop
  388. end
  389. % Define the standard handleerror.
  390. errordict begin
  391.   /handleerror
  392.    { (Error: ) print
  393.      $error begin
  394.        errorname ==only flush
  395.        ( in ) print
  396.        /command load ==only flush
  397.        currentdict /ostack known
  398.         { (\nOperand stack:\n  ) print ostack { (  ) print ==only } forall
  399.     } if
  400.        currentdict /estack known
  401.         { (\nExecution stack:\n  ) print estack { (  ) print =only } forall
  402.     } if
  403.        currentdict /dstack known
  404.     { (\nDictionary stack:\n  ) print dstack
  405.        { dup (  ) print length =only (/) print maxlength =only } forall
  406.     } if
  407.        (\n) print
  408.        errorname /VMerror eq
  409.         { (VM status:) print mark vmstatus
  410.       counttomark { ( ) print counttomark -1 roll dup =only } repeat
  411.       cleartomark (\n) print
  412.     } if
  413.        /newerror false def
  414.      end
  415.      currentdict /position known
  416.       { (Current file position is ) print position = }
  417.      if
  418.      flush
  419.      .instopped {stop} if
  420.    } bind def
  421. end
  422.  
  423. % Define the =[only] procedures.  Also define =print and =string,
  424. % which are used by some P*stScr*pt programs even though
  425. % they aren't documented anywhere.
  426. /=print    {=only} def
  427. /=string 128 string def
  428. /=    {=only (\n) print} bind def
  429. 4 dict begin
  430.   /.buf =string def
  431.   /.print
  432.     {dup type currentdict exch known
  433.      {dup type exec} {.buf cvs print} ifelse
  434.     } bind def
  435.   /stringtype
  436.     {dup rcheck not {pop (--nostringval--)} if print} bind def
  437.   /nametype
  438.     {dup length .buf length gt
  439.      {dup length string}
  440.      {.buf}
  441.     ifelse cvs print} bind def
  442. {0 begin .print end} copyarray dup 0 currentdict put
  443.   cvx bind
  444. end
  445. /=only exch def
  446.  
  447. % Define the [write]==[only] procedures.
  448. /==    {==only (\n) print} bind def
  449. /==only    {.stdout exch write==only} bind def
  450. /write==
  451.     {2 copy write==only pop (\n) writestring} bind def
  452. /.dict 18 dict dup
  453. begin def
  454.   /.buf 128 string def
  455.   /.cvp {.buf cvs .p} bind def
  456. % /.f {the_output_file} def
  457.   /.nop {(-) .p type .cvp (-) .p} bind def
  458.   /.p {.f exch writestring} bind def
  459.   /.p1 {.f exch write} bind def
  460.   /.print
  461.     {dup type .dict exch known
  462.      {dup type exec} {.nop} ifelse
  463.     } bind def
  464.   /integertype /.cvp load def
  465.   /nulltype { pop (null) .p } bind def
  466.   /realtype /.cvp load def
  467.   /booleantype /.cvp load def
  468.   /nametype
  469.     {dup xcheck not {(/) .p} if
  470.      dup length .buf length gt
  471.       {dup length string}
  472.       {.buf}
  473.      ifelse cvs .p} bind def
  474.   /arraytype
  475.     {dup rcheck
  476.       {dup xcheck {(})({)} {(])([)} ifelse .p
  477.        exch () exch
  478.        {exch .p .print ( )} forall pop .p}
  479.       {.nop}
  480.      ifelse} bind def
  481.   /operatortype
  482.       {(--) .p .cvp (--) .p} bind def
  483.   /packedarraytype /arraytype load def
  484.   /stringtype
  485.     {dup rcheck
  486.       {(\() .p
  487.        {/.ch exch def
  488.         .ch 32 lt .ch 127 ge or
  489.         {(\\) .p .ch 8#1000 add 8 .buf cvrs 1 3 getinterval .p}
  490.         {.ch 40 eq .ch 41 eq or .ch 92 eq or
  491.          {(\\) .p} if
  492.          .ch .p1}
  493.         ifelse}
  494.        forall (\)) .p}
  495.       {.nop}
  496.      ifelse} bind def
  497. {0 begin exch cvlit /.f exch def .print end} copyarray dup 0 .dict put
  498.   bind cvx
  499. end
  500. /write==only exch def
  501.  
  502. VMDEBUG
  503.  
  504. % Define the font directory.
  505. % Make it big to leave room for transformed fonts.
  506. /FontDirectory 100 dict def
  507.  
  508. % Define the standard encoding vector.
  509. /StandardEncoding
  510. % \00x
  511.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  512.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  513.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  514.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  515. % \04x
  516.     /space /exclam /quotedbl /numbersign
  517.     /dollar /percent /ampersand /quoteright
  518.     /parenleft /parenright /asterisk /plus
  519.     /comma /hyphen /period /slash
  520.     /zero /one /two /three
  521.     /four /five /six /seven
  522.     /eight /nine /colon /semicolon
  523.     /less /equal /greater /question
  524. % \10x
  525.     /at /A /B /C /D /E /F /G
  526.     /H /I /J /K /L /M /N /O
  527.     /P /Q /R /S /T /U /V /W
  528.     /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore
  529. % \14x
  530.     /quoteleft /a /b /c /d /e /f /g
  531.     /h /i /j /k /l /m /n /o
  532.     /p /q /r /s /t /u /v /w
  533.     /x /y /z /braceleft /bar /braceright /asciitilde /.notdef
  534. % \20x
  535.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  536.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  537.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  538.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  539. % \24x
  540.     /.notdef /exclamdown /cent /sterling
  541.     /fraction /yen /florin /section
  542.     /currency /quotesingle /quotedblleft /guillemotleft
  543.     /guilsinglleft /guilsinglright /fi /fl
  544.     /.notdef /endash /dagger /daggerdbl
  545.     /periodcentered /.notdef /paragraph /bullet
  546.     /quotesinglbase /quotedblbase /quotedblright /guillemotright
  547.     /ellipsis /perthousand /.notdef /questiondown
  548. % \30x
  549.     /.notdef /grave /acute /circumflex /tilde /macron /breve /dotaccent
  550.     /dieresis /.notdef /ring /cedilla /.notdef /hungarumlaut /ogonek /caron
  551.     /emdash /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  552.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  553. % \34x
  554.     /.notdef /AE /.notdef /ordfeminine /.notdef /.notdef /.notdef /.notdef
  555.     /Lslash /Oslash /OE /ordmasculine /.notdef /.notdef /.notdef /.notdef
  556.     /.notdef /ae /.notdef /.notdef /.notdef /dotlessi /.notdef /.notdef
  557.     /lslash /oslash /oe /germandbls /.notdef /.notdef /.notdef /.notdef
  558. 256 packedarray def
  559.  
  560. % Define the ISO Latin-1 encoding vector.
  561. % The first half is the same as the standard encoding.
  562. /ISOLatin1Encoding
  563. StandardEncoding 0 128 getinterval aload pop
  564. %*** NOTE: the following are missing in the Adobe documentation,
  565. %*** but appear in the displayed table:
  566. %*** macron at 225, dieresis at 230, cedilla at 233, space at 240.
  567. % \20x
  568.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  569.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  570.     /dotlessi /grave /acute /circumflex /tilde /macron /breve /dotaccent
  571.     /dieresis /.notdef /ring /cedilla /.notdef /hungarumlaut /ogonek /caron
  572. % \24x
  573.     /space /exclamdown /cent /sterling
  574.     /currency /yen /brokenbar /section
  575.     /dieresis /copyright /ordfeminine /guillemotleft
  576.     /logicalnot /hyphen /registered /macron
  577.     /degree /plusminus /twosuperior /threesuperior
  578.     /acute /mu /paragraph /periodcentered
  579.     /cedilla /onesuperior /ordmasculine /guillemotright
  580.     /onequarter /onehalf /threequarters /questiondown
  581. % \30x
  582.     /Agrave /Aacute /Acircumflex /Atilde
  583.     /Adieresis /Aring /AE /Ccedilla
  584.     /Egrave /Eacute /Ecircumflex /Edieresis
  585.     /Igrave /Iacute /Icircumflex /Idieresis
  586.     /Eth /Ntilde /Ograve /Oacute
  587.     /Ocircumflex /Otilde /Odieresis /multiply
  588.     /Oslash /Ugrave /Uacute /Ucircumflex
  589.     /Udieresis /Yacute /Thorn /germandbls
  590. % \34x
  591.     /agrave /aacute /acircumflex /atilde
  592.     /adieresis /aring /ae /ccedilla
  593.     /egrave /eacute /ecircumflex /edieresis
  594.     /igrave /iacute /icircumflex /idieresis
  595.     /eth /ntilde /ograve /oacute
  596.     /ocircumflex /otilde /odieresis /divide
  597.     /oslash /ugrave /uacute /ucircumflex
  598.     /udieresis /yacute /thorn /ydieresis
  599. 256 packedarray def
  600.  
  601. % Define a stub for the Symbol encoding.
  602. userdict begin
  603.   /SymbolEncoding
  604.    { userdict begin (sym__enc.ps) run /SymbolEncoding load end
  605.    } bind def
  606. end
  607.  
  608. % Construct a dictionary of all available devices.
  609. mark
  610.     % Loop until the getdevice gets a rangecheck.
  611.   0 { {dup getdevice exch 1 add} loop} stopped pop
  612.   dict /devicedict exch def
  613.   devicedict begin        % 2nd copy of count is on stack
  614.    { dup /Name gsgetdeviceprop cvn dup 3 -1 roll def
  615.      counttomark 1 roll
  616.    } repeat
  617.   end
  618. ] /devicenames exch def
  619. $error /newerror false put        % remove error indication
  620.  
  621. % Define statusdict, for the benefit of programs
  622. % that think they are running on a LaserWriter or similar printer.
  623. (gs_statd.ps) run
  624.  
  625. % Load the initialization files for optional features.
  626. (gconfig.ps) run
  627.  
  628. % Establish a default upper limit in the character cache,
  629. % namely, 10 times the average expected character size.
  630. mark
  631.  cachestatus 5 index 10 mul 2 index 1 max idiv        % bmax, cmax
  632.   mark exch dup 10 idiv exch setcacheparams
  633. cleartomark
  634. % Conditionally disable the character cache.
  635. NOCACHE { 1 setcachelimit } if
  636.     
  637. VMDEBUG
  638.  
  639. % Load the standard font environment.
  640. (gs_fonts.ps) run
  641.  
  642. % Create a null font.  This is the initial font.
  643. 7 dict dup begin
  644.   /FontMatrix [ 1 0 0 1 0 0 ] def
  645.   /FontType 3 def
  646.   /FontName () def
  647.   /Encoding StandardEncoding def
  648.   /FontBBox { 0 0 0 0 } def    % executable is bogus, but customary ...
  649.   /BuildChar { pop pop 0 0 setcharwidth } bind def
  650. end
  651. /NullFont exch definefont setfont
  652. % Define NullFont as the font, but remove it from FontDirectory.
  653. /NullFont currentfont def
  654. FontDirectory /NullFont undef
  655.  
  656. % Check for precompiled fonts.
  657. /CompiledFonts where
  658.  { CompiledFonts exch /CompiledFonts undef { definefont pop } forall
  659.  }
  660. if
  661.  
  662. % Restore the real definition of run.
  663. /run /.run load def
  664. currentdict /.run undef
  665.  
  666. % Bind all the operators defined as procedures.
  667. % Temporarily disable the typecheck error.
  668. errordict /typecheck get
  669. errordict /typecheck { pop } put    % pop the command
  670. systemdict
  671.  { dup type /operatortype eq
  672.     { % This might be a real operator, so bind might cause a typecheck,
  673.       % but we've made the error a no-op temporarily.
  674.       bind
  675.     }
  676.    if pop pop
  677.  } forall
  678. errordict /typecheck 3 -1 roll put
  679.  
  680. % Close up systemdict.
  681. end
  682. WRITESYSTEMDICT not { systemdict readonly pop } if
  683.  
  684. % Establish a default environment.
  685. DISPLAYING
  686.  { systemdict /DEVICE known
  687.     { devicedict DEVICE known not
  688.        { (Unknown device: ) print DEVICE =
  689.          flush quit
  690.        }
  691.       if
  692.     }
  693.    if
  694.    defaultdevice
  695.    false [ /DEVICEWIDTH /DEVICEHEIGHT /DEVICEXRESOLUTION /DEVICEYRESOLUTION ]
  696.     { systemdict exch known or }
  697.    forall
  698.     {        % Adjust the device parameters per the command line.
  699.       getdeviceprops dicttomark begin
  700.       6 dict begin
  701.       /dw HWSize 0 get def
  702.       /dh HWSize 1 get def
  703.       /dmat InitialMatrix def
  704.       /dxres HWResolution 0 get def
  705.       /dyres HWResolution 1 get def
  706.       /DEVICEXRESOLUTION where
  707.        { pop /drq DEVICEXRESOLUTION dxres div def
  708.          0 2 4
  709.       { dup
  710.         dmat exch get drq mul
  711.         dmat 3 1 roll put
  712.       }
  713.      for
  714.      dw drq mul cvi /dw exch def
  715.          /dxres DEVICEXRESOLUTION def
  716.        }
  717.       if
  718.       /DEVICEYRESOLUTION where
  719.        { pop /drq DEVICEYRESOLUTION dyres div def
  720.          1 2 5
  721.       { dup
  722.         dmat exch get drq mul
  723.         dmat 3 1 roll put
  724.       }
  725.      for
  726.      dh drq mul cvi /dh exch def
  727.          /dyres DEVICEYRESOLUTION def
  728.        }
  729.       if
  730.       /DEVICEWIDTH where
  731.        { pop /dw DEVICEWIDTH def }
  732.       if
  733.       /DEVICEHEIGHT where
  734.        { pop /dh DEVICEHEIGHT def
  735.        }
  736.       if
  737.       mark
  738.       /HWSize [ dw dh ] /HWResolution [ dxres dyres ] /InitialMatrix dmat
  739.       defaultdevice putdeviceprops
  740.       end end
  741.     }
  742.    if
  743.    systemdict /OUTPUTFILE known
  744.     { mark /OutputFile OUTPUTFILE 4 -1 roll putdeviceprops
  745.     }
  746.    if
  747.    setdevice        % does an erasepage
  748.  }
  749.  { nulldevice
  750.  }
  751. ifelse
  752. 1 setflat        % initgraphics doesn't set this
  753. { } settransfer        % ditto
  754.  
  755. 72 72 dtransform abs exch abs min    % min(|dpi x|,|dpi y|)
  756. dup 200 lt systemdict /DITHERPPI known not and
  757.  {        % Low-res device, use ordered dither spot function
  758.     % The following 'ordered dither' spot function was contributed by
  759.     % Gregg Townsend.  Thanks, Gregg!
  760.   16.001 div 0            % not 16: avoids rounding problems
  761.    { 1 add 7.9999 mul cvi exch 1 add 7.9999 mul cvi 16 mul add <
  762.     0E 8E 2E AE 06 86 26 A6 0C 8C 2C AC 04 84 24 A4
  763.     CE 4E EE 6E C6 46 E6 66 CC 4C EC 6C C4 44 E4 64
  764.     3E BE 1E 9E 36 B6 16 96 3C BC 1C 9C 34 B4 14 94
  765.     FE 7E DE 5E F6 76 D6 56 FC 7C DC 5C F4 74 D4 54
  766.     01 81 21 A1 09 89 29 A9 03 83 23 A3 0B 8B 2B AB
  767.     C1 41 E1 61 C9 49 E9 69 C3 43 E3 63 CB 4B EB 6B
  768.     31 B1 11 91 39 B9 19 99 33 B3 13 93 3B BB 1B 9B
  769.     F1 71 D1 51 F9 79 D9 59 F3 73 D3 53 FB 7B DB 5B
  770.     0D 8D 2D AD 05 85 25 A5 0F 8F 2F AF 07 87 27 A7
  771.     CD 4D ED 6D C5 45 E5 65 CF 4F EF 6F C7 47 E7 67
  772.     3D BD 1D 9D 35 B5 15 95 3F BF 1F 9F 37 B7 17 97
  773.     FD 7D DD 5D F5 75 D5 55 FF 7F DF 5F F7 77 D7 57
  774.     02 82 22 A2 0A 8A 2A AA 00 80 20 A0 08 88 28 A8
  775.     C2 42 E2 62 CA 4A EA 6A C0 40 E0 60 C8 48 E8 68
  776.     32 B2 12 92 3A BA 1A 9A 30 B0 10 90 38 B8 18 98
  777.     F2 72 D2 52 FA 7A DA 5A F0 70 D0 50 F8 78 D8 58
  778.    > exch get 256 div } bind 
  779.  }
  780.  {        % Hi-res device, use dot spot function
  781.     % The following 'Niksula dither' was contributed by Hannu Aronsson
  782.     % (haa@cs.hut.fi).  It is a better dither for most hi-res printers.
  783.     % 32.5 is the best value of DITHERPPI for the 400 dpi Sony NWP533
  784.     % printer.
  785.    pop systemdict /DITHERPPI known { DITHERPPI } { 32.5 } ifelse
  786.    0
  787.     { exch abs exch abs   2 copy le { exch } if
  788.       exch 1 sub dup mul exch dup mul add 1 exch sub
  789.     } bind
  790.  } ifelse
  791. setscreen
  792. initgraphics
  793. % The interpreter relies on there being at least 2 entries
  794. % on the graphics stack.  Establish the second one now.
  795. gsave
  796.  
  797. VMDEBUG
  798.  
  799. % Define control-D as a no-op.  This is a hack to get around problems
  800. % in some common PostScript-generating applications.
  801. (\004) cvn { } def
  802. (\004\004) cvn { } def
  803.  
  804. % Turn off array packing for interactive use.
  805. false setpacking
  806.  
  807. QUIET not { (done.\n) print flush } if
  808.  
  809. % The interpreter will run the initial procedure (start).
  810.